
function figVec=plot2StateMatsDiff(matOne,matTwo,names,xaxis,figStru,addSuptitle) 
% function plot2StateMats(matOne,matTwo,names,xaxis,figStru,layout) 
% 
%% plot2StateMats 
%  Given two matrices of state, plot one against the other 
%  in the same subplot 
% 
%% Inputs
%  matOne   [nobs ns]   matrix of states
%  matTwo   [nobs ns]   matrix of states 
%  names    structure with 
%           states. [ns    1]   cell with names 
%           legend. [2     1]   legend for each matrix 
%           title.  [2     1]   title for each subplot 
%  xaxis    [nobs  1]   x-axis vector 
%  figStru 
%  layout   [2 1]       vector [rows,cols] per figure 
%           if empty will plot 1 per figure; 
[nobs ns]=size(matOne); 
if nargin < 7 || isempty(addSuptitle)
    addSuptitle=[]; 
end 

figVec=zeros(ns,1);
    
for ii=1:ns;
    figVec(ii)=figure;
    subplot(2,1,1);
    figStru.flagNoLegend=0;
    figStru.legend=names.legend;
    plot3samp(xaxis,[matOne(:,ii) matTwo(:,ii)],figStru);
    title(char( names.title{1} ) );
    
    subplot(2,1,2);
    figStru.flagNoLegend=1;
    plot3samp(xaxis,matOne(:,ii)-matTwo(:,ii),figStru);
    hHandle=hline(0); 
    set(hHandle,'Color','b','LineStyle','--'); 
    title(names.title{2});
    if isempty(addSuptitle)==true
        suptitle(char(names.states{ii}));
    else
        suptitle([char(addSuptitle),' ',char(names.states{ii})]);
    end
end
